﻿#region using statements

using Microsoft.Xna.Framework;

using NGen;
using NGen.Managers.GUI;
using NGen.Managers.GameObject;
using NGen.Managers.GameState;

using XNAGameDemo.GUI;
using XNAGameDemo.GameObjects;

#endregion

namespace XNAGameDemo.GameStates
{
	public class GameStatePlay1 : GameState
	{
		/// <summary>
		/// 	the gui to load
		/// </summary>
		private readonly GUIElement m_gui = new GUIElementPlay1State();

		protected override void _Initialize() {
			//load the gui
			GameEngine.GetService<IManagerGUI>().AddElement(m_gui);

			//create an object to store the points, add it as a service
			GameEngine.GameServices.AddService(typeof(Play1Score), new Play1Score());

			//create 50 bouncing balls
			for(var i = 0; i < 50; ++i) {
				GameEngine.GetService<IManagerGameObjects>().AddObject(new BouncingBall());
			}
		}

		protected override void _Cleanup() {
			//remove the gui
			GameEngine.GetService<IManagerGUI>().RemoveElement(m_gui);

			//kill all remaining balls
			GameEngine.GetService<IManagerGameObjects>().DestroyAllGameObjects();

			//get rid of the points tracking service
			GameEngine.GameServices.RemoveService(typeof(Play1Score));
		}

		protected override void _OnFocusLost() {}

		protected override void _OnFocusGained() {}

		protected override void _Update(GameTime p_gameTime) {}

		protected override void _Draw(GameTime p_gameTime) {
			GameEngine.GraphicsDeviceManager.GraphicsDevice.Clear(Color.Transparent);
		}

		#region Nested type: Play1Score

		/// <summary>
		/// 	a class which simply stores points
		/// </summary>
		public class Play1Score
		{
			public int m_points;
		}

		#endregion
	}
}